package org.goldenport.g3.messages.datastore

import org.goldenport.g3.messages._
import org.goldenport.g3.atom._

/**
 * @since   Jan.  4, 2011
 * @version Jan.  5, 2011
 * @author  ASAMI, Tomoharu
 */
class DataStoreManifest(val recordClassSpace: RecordClassSpace) extends Object with AppServiceable with Jsonable {
  def toAppService(cmd: RestCommand): AppService = {
    def workspaces = {
        List(AppWorkspace(AtomTitle("datastore"),
                          collections))
    }

    def collections = {
      for (c <- recordClassSpace.classes) yield {
        AppCollection(AtomTitle(c.uri.name), c.uri.name)
      }
    }

    AppService(workspaces)
  }

  def toJson(cmd: RestCommand): String = {
    toAppService(cmd).toJson
  }
}
